package com.maoning.product.web;

import com.maoning.product.service.SkuInfoService;
import com.maoning.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

/**
 * @Author : 猫宁
 * @Date: 2022/2/27
 */
@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    @RequestMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId")Long skuId, Model model) throws ExecutionException, InterruptedException {
        System.out.println("要展示的商品id是:" + skuId);
        final SkuItemVo skuItemVo = skuInfoService.getSkuItemVoById(skuId);
        model.addAttribute("item", skuItemVo);
        return "item";
    }
}
